﻿/* ****************************************************************************
* Copyright (c) TCC - 2009 IME - USP. 
*
* This source code is subject to terms and conditions of the Microsoft Public License. 
* A copy of the license can be found in http://msdn.microsoft.com/en-us/library/dd228915.aspx. 
* By using this source code in any fashion, you are agreeing to be bound by the terms of the 
* Microsoft Public License.
*
* You must not remove this notice, or any other, from this software.
* ***************************************************************************/

using System;

namespace SoundLibrary.Converter
{
    internal enum OutputChannelsEnum
    {
        BOTH_CHANNELS = 0,
        LEFT_CHANNEL = 1,
        RIGHT_CHANNEL = 2,
        DOWNMIX_CHANNELS = 3
    }

    internal static class Util
    {
        private static int[] bitMask = new int[]
        {
            0, 0x00000001, 0x00000003, 0x00000007, 0x0000000F, 0x0000001F, 0x0000003F, 0x0000007F, 0x000000FF, 0x000001FF, 0x000003FF, 0x000007FF, 0x00000FFF, 0x00001FFF, 0x00003FFF, 0x00007FFF, 0x0000FFFF, 0x0001FFFF
        };

        public static int URShift(int number, int bits)
        {
            if (number >= 0)
            {
                return number >> bits;
            }
            else
            {
                return (number >> bits) + (2 << ~bits);
            }
        }

        public static int[] BitMask
        {
            get { return bitMask; }
            set { bitMask = value; }
        }

        public static long Identity(long literal)
        {
            return literal;
        }
    }
}
